package com.jake.mallcrud.service.impl;

import com.jake.mallcrud.dao.UserDao;
import com.jake.mallmodel.entity.User;
import com.jake.mallmodel.entity.UserInfo;
import com.jake.mallcrud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public List<User> findAllUsers() {
        return userDao.findAllUsers();
    }

    @Override
    public List<User> findAllUserInfo() {
        return userDao.findAllUserInfo();
    }

    @Override
    public User findUserById(Integer uid) {
        return userDao.findUserById(uid);
    }

    @Override
    public UserInfo findUserInfoById(Integer uid) {
        return userDao.findUserInfoById(uid);
    }

    @Override
    public List<UserInfo> findUserInfoByUsernameAndCname(String username, String cname) {
        return userDao.findUserInfoByUsernameAndCname(username, cname);
    }

    @Override
    public void createUser(User user) {
        userDao.insertUser(user);
    }

    @Override
    public void updateUser(User user) {
        userDao.updateUser(user);
    }

    @Override
    public void removeUserById(Integer uid) {
        userDao.deleteUserById(uid);
    }

}
